/*
 *    Copyright (c) 2018-2025, nart All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: nart
 */

package com.nai365.nart.operation.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nai365.nart.operation.dto.BuySpuDto;
import com.nai365.nart.operation.dto.BuySpuNotifyDto;
import com.nai365.nart.operation.entity.Preemption;
import com.nai365.nart.operation.exception.PreemptionException;
import com.nai365.nart.operation.dto.PreemptionDto;

import java.util.List;

/**
 * 优先购
 *
 * @author 罗光林
 * @date 2022-07-01 11:13:17
 */
public interface PreemptionService extends IService<Preemption> {

	Page<PreemptionDto> page(Page<Preemption> page, Wrapper<Preemption> preemption);

	/**
	 * 根据Spu查询可用优先购
	 *
	 * @param spuId SPU ID
	 * @return 优先购
	 */
	List<PreemptionDto> findBySpu(Long spuId) throws PreemptionException;

	/**
	 * 优先购下单
	 *
	 * @param buySpuDto 下单参数
	 * @return 订单编号
	 * @throws Exception
	 */
	String buySpu(BuySpuDto buySpuDto) throws Exception;

	/**
	 * 优先购支付回调
	 *
	 * @param buySpuDto 回调参数
	 * @return 调用状态
	 * @throws Exception
	 */
	Boolean buySpuNotify(BuySpuNotifyDto buySpuDto) throws Exception;

	PreemptionDto getPreemptionDtoBy(Long id);


}
